// test-audio-api.js
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

async function testAudioAPI() {
    try {
        console.log('Testing audio transcription API...');
        
        // 首先测试健康检查端点
        const healthResponse = await axios.get('http://localhost:5001/health');
        console.log('Whisper API Health Check:', healthResponse.data);
        
        // 如果需要测试音频转录，可以取消下面的注释
        // 并提供一个实际的音频文件路径
        /*
        const form = new FormData();
        // 你需要提供一个实际的音频文件路径
        const audioFilePath = './test-audio.wav'; // 替换为实际的音频文件路径
        form.append('audio', fs.createReadStream(audioFilePath));
        
        const response = await axios.post('http://localhost:3000/api/audio/transcribe', form, {
            headers: {
                ...form.getHeaders(),
                // 如果需要认证，添加认证头
                // 'x-auth-token': 'your-jwt-token-here'
            },
        });
        
        console.log('Transcription result:', response.data);
        */
        
        console.log('Audio API test completed successfully!');
    } catch (error) {
        console.error('Error testing audio API:', error.message);
        if (error.response) {
            console.error('Response data:', error.response.data);
            console.error('Response status:', error.response.status);
        }
    }
}

testAudioAPI();